package com.ruleengine.context;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class WorkflowContextPool {
    private static volatile WorkflowContextPool pool;
    private Map<String, IWorkflowConext> contexts;
    private WorkflowContextPool(){
        contexts = new ConcurrentHashMap<String, IWorkflowConext>();
    }
    
    public static WorkflowContextPool getInstance(){
        if(pool == null){
            synchronized(WorkflowContextPool.class){
                if(pool == null){
                    pool = new WorkflowContextPool();
                }
            }
        }
        return pool;
    }
    
    public IWorkflowConext removeWorkflowContext(String key){
        return contexts.remove(key);
    }
    
    public void putWorkflowContext(String key, IWorkflowConext value){
        contexts.put(key, value);
    }
}
